import Vue from 'vue'
// 2. 导入vuex包
import Vuex from 'vuex'

Vue.use(Vuex)

// 3. 创建store对象
const store = new Vuex.Store({
  // state 中存放的就是全局共享的数据
  state: {
    count: 0,
    // 无人机经纬高
    longitude: 0,
    latitude: 0,
    height: 0,
    // 水平仪的经纬高
    lon: 0,
    lat: 0,
    hgt: 0
  },
  mutations: {
    /**
     * 无人机state数据变更
     */
    editWrjLon(state, step) {
      state.wrjLon = step
    },
    editWrjLat(state, step) {
      state.wrjLat = step
    },
    editHeight(state, step) {
      state.wrjHgt = step
    },
    /**
     * 水平仪state数据变更
     */
    editSpyLon(state, step) {
      state.spyLon = step
    },
    editSpyLat(state, step) {
      state.spyLat = step
    },
    editSpyHgt(state, step) {
      state.spyHgt = step
    }
  },
  actions: {
    addAsync(context, step) {
      // eslint-disable-next-line no-undef
      seTimeout(() => {
        context.commit('add', step)
      }, 1000)
    }
  },
  getters: {
    showNum: state => {
      return '当前最新的数量是【"+ state.count +"】'
    }
  }
})

export default store
